package com.vhall.component.plugin.common.utils.algorithm;

import cn.hutool.crypto.digest.DigestUtil;

/**
 * SHA256签名生成
 *
 * @author yuanzh
 * @date 2021/9/8
 */
public class Sha256SignGenerator implements ISignGenerator {

    @Override
    public String sign(String content, String signKey, String charset) {
        return DigestUtil.sha256Hex(signKey + content + signKey, charset);
    }

    @Override
    public boolean verify(String content, String charset, String signKey, String signature) {
        String generateSign = sign(content, signKey, charset);
        return generateSign.equalsIgnoreCase(signature);
    }

}
